home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor1 / pack.doc < prev    next >
Text File  |  1995-03-31  |  3KB  |  55 lines

  1. PACK, a program packer, by Joseph K. Horn. 
  2.  
  3. [Note: This PACK is a stand-alone program.  A shorter version of PACK 
  4. which calls other routines is in the IO file on this disk. -jkh-] 
  5.  
  6. Purpose: Shrinks and speeds up programs that contain SYSEVALs.  Has no 
  7. effect on programs that do not contain SYSEVALs. 
  8.  
  9. Instructions: Recall program object to the stack.  Run PACK.  Store the 
  10. new program object into a new name or into its old variable name if so 
  11. desired. The newly PACKed program will be shorter and run faster than 
  12. the old one. 
  13.  
  14. Theory: The SYSEVAL instruction takes a binary integer as its argument.  
  15. But a binary integer followed by SYSEVAL takes up 31 nibbles, and can be 
  16. replaced by just the leading five nibbles of the binary integer.  Such 
  17. replacement not only uses less memory, but runs faster.  Unfortunately, 
  18. these objects do not have names, and show up in listings as "External", 
  19. rendering the program unreadable and uneditable.  But it runs just fine. 
  20.  
  21. Note well: PACK was intended for use on programs, but performs the same 
  22. packing on lists.  If a list contains a binary integer immediately 
  23. followed by a SYSEVAL, both will be replaced by the equivalent External 
  24. object. 
  25.  
  26. PACK should only be used on the final version of a program, because once 
  27. a program contains External objects, it is not editable by normal 
  28. methods.  A good practice might be to keep an "original version" with 
  29. SYSEVALs, and a "working copy" PACKed and ready to use, in two separate 
  30. variables. 
  31.  
  32. EXAMPLE 1:  You wish to make a key assignment that puts you into the 
  33. hidden directory.  Let's put it on the POLAR key.  Normally you'd do 
  34. this: 
  35.  
  36.      {  <<  HOME  #15781h  SYSEVAL  2  MENU  >>  82.3  } 
  37.  
  38. and then press STOK (in the blue-CST menu).  That would work.  But 
  39. before you press STOK, run PACK; the list becomes { << HOME External 2 
  40. MENU >> 82.3 } because the address #15781h and the SYSEVAL got replaced 
  41. by the equivalent External object.  Now press STOK, and the assignment 
  42. will be 26 nibbles shorter and a little bit faster.  (If you actually did 
  43. this example, you may delete this key assignment, if you wish, by typing 
  44. 82.3 and pressing DELK.) 
  45.  
  46. EXAMPLE 2:  You have a program that looks like this: 
  47.  
  48. <<  #18CD7 SYSEVAL  #21922 SYSEVAL  #3DEF SYSEVAL  #62F89 SYSEVAL  >> 
  49.  
  50. It takes a port number (0, 1 or 2) and recalls that port's objects onto 
  51. the stack.  It is 72 bytes long (checksum: #CBDAh).  PACK it, and it 
  52. shrinks to only 20 bytes long, but is no longer readable or editable. 
  53.  
  54. Thanks to Rick Grevelle & Derek Nickel for the tools used here. 
  55.